<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<%@page import="gestores.GestorUsuario"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Agregar a Educado</title>
</head>
<body>

<jsp:include page="../control/sessionRegistrado.jsp"></jsp:include> 
<%

Object ologin = session.getAttribute("session.user");
Object ouser = request.getParameter("usuario");

Object onum = request.getParameter("num");
if(ouser==null||onum==null){
	  response.sendRedirect("FrontController?res=content.jsp");
	}



String user = (String)ouser;
String login = (String)ologin;

String snum = (String)onum;
Integer num = new Integer(snum);
if(login=="" || user ==""|| num<0 || num>1){
	response.sendRedirect("FrontController?res=control/content.jsp");
	}

GestorUsuario gu = new GestorUsuario();


	String RegExPattern = "[a-zA-Z0-9]{5,30}";
	if (!user.matches(RegExPattern)) {
		response.sendRedirect("FrontController?res=educadores/educadores.jsp");
			
	} else{
		if(num==0){
		gu.agregarEducado(login,user);
		response.sendRedirect("FrontController?res=educadores/educadores.jsp");
		
		}else{
			gu.agregarEducado(user,login);
			response.sendRedirect("FrontController?res=educadores/educadores.jsp");
				
		}
	}


%>

</body>
</html>